home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / log_user.arc / LOG_USER.BAT
DOS Batch File  |  1986-09-17  |  6KB  |  153 lines

  1. rem    This program is used to permit local area network administrators
  2. rem    to restrict access to single-user software programs in accordance
  3. rem    with the number of licenses that have been purchased.
  4. rem
  5. rem    The example below is set up to give three users access to one 
  6. rem    copy of LOTUS 1-2-3 (tm) and prevent any further access until
  7. rem    one of the three exit LOTUS.
  8. rem 
  9. rem    You must rename this program with the name you would usually
  10. rem    use to call the software and rename the software itself to 
  11. rem    something else. In our example, this file would be named 
  12. rem    LOTUS.BAT, and we have to rename LOTUS itself to L123.COM.
  13. rem    So you will notice that our program call used below (for purpose
  14. rem    of example) is L123.
  15. rem    
  16. rem    No directory changes are shown in this example, but you must be
  17. rem    very careful to always be in the same directory when the user
  18. rem    enters and exits the program. So, for example, if I have Lotus
  19. rem    in my \LOTUS subdirectory and this file (LOG_USER.BAT) in the 
  20. rem    root directory, I would have to change to my /LOTUS directory
  21. rem    before calling Lotus, and change back to the root directory
  22. rem    after exiting Lotus. You can see how un-necessarily complex this
  23. rem    is. You will always be better off keeping this program in the 
  24. rem    same directory as the software that is being protected IF YOU
  25. rem    CAN. Not all software returns you to the directory you started
  26. rem    the program from! This is especially true of programs like 
  27. rem    SMART that allow you to establish "data paths" to
  28. rem    keep the programs separate from the data files.
  29. rem    
  30. rem    IF LOG_USER EVER FAILS TO WORK, IT IS PROBABLY BECAUSE YOU ARE 
  31. rem    NOT PUTTING THE USER IN THE PROPER DIRECTORY TO CREATE AND 
  32. rem    DELETE THE USER?.LOG FILES.
  33. rem
  34. rem    PROGRAM: LOG_USER
  35. rem    Do not display commands
  36. rem
  37. echo off
  38. rem
  39. rem    Check for active users, starting with largest number possible.
  40. rem
  41. if exist USER3.LOG goto NOT_AVAIL
  42. if exist USER2.LOG goto LAST_ONE
  43. if exist USER1.LOG goto SECOND_USER
  44. rem    
  45. rem    If the person attempting to log on gets this far, then he or she
  46. rem    Is the first user so we write a dummy file (which may contain
  47. rem    Anything--we just need the file name to be in the directory) and
  48. rem    Then let them into the software. XXX is a dummy file containing 
  49. rem    One character. It is used for copying. The copy command would 
  50. rem    Normally issue the message "1 File(s) Copied" but we suppress this
  51. rem    By redirecting it to the NUL device as shown.
  52. rem 
  53. copy XXX USER1.LOG >nul:
  54. rem
  55. rem    Then we call the program...
  56. rem 
  57. L123
  58. rem 
  59. rem    After the user exits the program, we have to erase a dummy
  60. rem    file so we use the procedure CLEAR_USER
  61. rem
  62. goto CLEAR_USER
  63. rem
  64. rem    Now we must check for cases where the user was not the first 
  65. rem    one to log onto the software. 
  66. rem
  67. rem    If one user is already on, we must set a second user log file
  68. rem    in the directory and be ready to erase a dummy file when the second
  69. rem    user exits.
  70. rem
  71. :SECOND_USER
  72. copy XXX USER2.LOG >nul:
  73. L123
  74. goto CLEAR_USER
  75. rem
  76. rem    If two users are already on, we must set a third user
  77. rem    log file in the directory and be ready to erase a dummy file when
  78. rem    the third user exits.
  79. rem
  80. :LAST_ONE
  81. copy XXX USSER3.LOG >nul:
  82. L123
  83. goto CLEAR_USER
  84. rem
  85. rem    If all three users are already logged on, then we gently inform
  86. rem    this user that he cannot access the software right now.
  87. rem
  88. :NOT_AVAIL
  89. cls
  90. echo          All Available Copies Of LOTUS 1-2-3 Are In Use.
  91. echo                  Please Try Again Later.
  92. pause
  93. goto END
  94. rem
  95. rem    Now, as these users log off of LOTUS, we must be ready to let
  96. rem    other users on, so we clear the log files we have been 
  97. rem    creating as they logged on. We do this in reverse order, so
  98. rem    the largest numbered log file is deleted first. This means that
  99. rem    the log files correctly represent the number of users logged
  100. rem    on regardless of the order they logged on and off.
  101. rem
  102. :CLEAR_USER
  103. if exist USER3.LOG goto ONE_FREE
  104. if exist USER2.LOG goto TWO_FREE
  105. rem
  106. rem    If the user has gotten this far, then he is the only one logged
  107. rem    on, and we only need to delete the last log file. As we did
  108. rem    with the copy command, we redirect the output to the NUL device.
  109. rem
  110. del USER1.LOG >nul:
  111. goto END
  112. rem
  113. rem    If all three users were logged on, we need to delete the last log
  114. rem    file and then exit.
  115. rem
  116. :ONE_FREE
  117. del USER3.LOG >nul:
  118. goto END
  119. rem
  120. rem    If Two users were logged on, we need to delete the middle user 
  121. rem    log file and then exit.
  122. rem
  123. :TWO_FREE
  124. del USER2.LOG >nul:
  125. rem
  126. rem    Now we can return to DOS.
  127. rem
  128. :END
  129. cls
  130. echo Returning to DOS...
  131. rem    
  132. rem    Problems can crop up in two different cases when using this
  133. rem    system. If the user types Ctrl-Break while the batch file is
  134. rem    executing, or if he resets his PC after having entered the
  135. rem    protected software, some log files can be left hanging open
  136. rem    when no one is actually on the software. For this reason, the
  137. rem    AUTOEXEC.BAT file on the server should contain the command
  138. rem    
  139. rem                del USER?.LOG >nul:
  140. rem    
  141. rem    to make sure all log files are cleared during a network reset.
  142. rem    
  143. rem    Don Merz
  144. rem    Blue Cross of Western Pennsylvania
  145. rem    1 Smithfield Street
  146. rem    Pittsburgh, Pa. 15222
  147. rem    (412) 255 - 7444
  148.  
  149.  
  150.  
  151.  
  152.    
  153.